<template>
  <div>
    <t-space direction="horizontal">
      <t-radio-group v-model="testItem">
        <t-radio-button value="1">直联商户</t-radio-button>
        <t-radio-button value="2">服务商</t-radio-button>
      </t-radio-group>
      <t-form>
        <t-form-item label="收银台地址"
          ><t-input v-model="cashierUrl" style="width: 300px" placeholder="请输入交易宝收银台地址"></t-input>
          <!-- <t-button theme="primary" @click="save">保存</t-button> -->
        </t-form-item>
      </t-form>
    </t-space>

    <api-doc v-if="testItem === '1'" :data="DIRECT_DATA"></api-doc>
    <api-doc v-if="testItem === '2'" :data="SERVICE_DATA"></api-doc>
  </div>
</template>
<script lang="ts">
export default {
  name: 'TenpayIndex',
};
</script>
<script setup lang="ts">
import { MessagePlugin } from 'tdesign-vue-next';
import { ref } from 'vue';
import ApiDoc from './components/ApiDocTable.vue';
import { DIRECT_DATA, SERVICE_DATA } from './constants';
import { useSettingStore } from '@/store';

const testItem = ref('1');

const settingStore = useSettingStore();
const cashierUrl = ref('');
const getCashierUrl = () => {
  cashierUrl.value = settingStore.cashierUrl;
};
getCashierUrl();
const save = () => {
  settingStore.saveCashier(cashierUrl.value);
  if (cashierUrl.value !== '') {
    MessagePlugin.success('保存成功');
  } else {
    MessagePlugin.warning('收银台地址己清空');
  }
};
</script>

<style></style>
